package Game;

import Game.ManagerSound.Type;


public class Ball extends GameObject
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public float speedx, speedy;
	
	public Ball (float x, float y, int w, int h, float speedx, float speedy)
	{
		super (x, y, w, h);
		
		Load("/Imagens/ball.png");
		
		this.speedx = speedx;
		this.speedy = speedy;
	}
	
	public void Arkanoid ()
	{
		this.x += this.speedx;
		this.y += this.speedy;
		
		if (this.y < 0)
			this.speedy *= y++;
		else if (this.y > 600 - this.h)
			this.speedy *= y--;
	}
	
	public void Pong(GameObject Player1, GameObject Player2, GameObject Barreira1, GameObject Barreira2)
	{
		this.x += this.speedx;
		this.y += this.speedy;
		
		if (this.y < 0)
		{
			this.speedy = -this.speedy;
			ManagerSound.getIntance().Play(Type.COLLISION);
		}

		if(this.y > 600 - this.h)
		{
			this.speedy = -this.speedy;
			ManagerSound.getIntance().Play(Type.COLLISION);
		}
		
		if (this.Collision(Player1) || this.Collision(Player2) || this.Collision(Barreira1) || this.Collision(Barreira2))
		{
			this.speedx = -this.speedx;
			ManagerSound.getIntance().Play(Type.COLLISION);
		}
	}
	
	public void Gradius()
	{
		speedx += this.speedx;
		this.x++;
	}
	
	public void GradiusEnemy()
	{
		speedx += this.speedx;
		this.x--;
	}
	
	public void SpaceInvaders()
	{
		speedy += this.speedy;
		this.y -= 3;
	}

	public void SpaceInvadersEnemy()
	{
		speedy += this.speedy;
		this.y++;
	}
	
}
